package LeetCode.month01.day01;

import java.util.Arrays;
import java.util.Scanner;

public class No128 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.nextLine();
        String[] chs = s.split(",");

        int[] a = new int[chs.length];
        for (int i = 0; i < chs.length; i++) {
            a[i] = Integer.parseInt(chs[i]);
        }
        System.out.println(longestConsecutive(a));
    }

    public static int longestConsecutive(int[] nums) {
        if(nums.length==0) return 0;
        Arrays.sort(nums);
        System.out.println();
        for (int i = 0; i < nums.length; i++) {
            System.out.print(nums[i]+",");
        }
        int maxlength = 1;
        int length = 1;
        for (int i = 1; i < nums.length; i++) {
            int num = nums[i]-nums[i-1];
            if(num > 1){
                maxlength = maxlength>length?maxlength:length;
                length=1;
            }else if(num == 1) length++;
        }
        return maxlength>length?maxlength:length;
    }
}
